Skip to content

small cleanups in rustc_codegen_llvm - #165622

Open
malezjaa wants to merge 6 commits into
rust-lang:mainfrom
malezjaa:cleanup-llvm-codegen
Open

malezjaa wants to merge 6 commits into
rust-lang:mainfrom
malezjaa:cleanup-llvm-codegen

Conversation

@malezjaa

@malezjaa malezjaa commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

small clippy cleanups

@rustbot

rustbot commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_codegen_llvm/src/debuginfo

cc @Walnut356

Some changes occurred in compiler/rustc_codegen_llvm/src/builder/autodiff.rs

cc @ZuseZ4

Some changes occurred in coverage instrumentation.

cc @Zalathar

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. F-autodiff `#![feature(autodiff)]` S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 8, 2026
@rustbot

rustbot commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

r? @dingxiangfei2009

rustbot has assigned @dingxiangfei2009.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 79 candidates
  • Random selection from 23 candidates

@rust-bors

This comment has been minimized.

@Zalathar

Zalathar commented Nov 8, 2026

Copy link
Copy Markdown
Member

This is a large number of individual changes mixed together (despite the modest line count), some of which are more contentious than others, which makes reviewing this a bit of a slog.

I'd suggest separating the different kinds of changes into separate commits, to make it easier to check that each kind of change looks good.

let value_words = [value as u64, (value >> 64) as u64];
let size_in_bits = size.bits();
// LLVM computes `NumWords = (SizeInBits + 63) / 64`.
assert!((size_in_bits + 63) / 64 <= value_words.len() as u64);

@Zalathar Zalathar Nov 8, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion is deliberately written to match the LLVM computation, and should not be changed, since the change makes it harder to verify that both sides are performing the same computation.

View changes since the review

Comment on lines +254 to +260
feature_err(
self.sess(),
feature,
span,
"C-variadic function definitions on this target are unstable",
)
.emit();

@Zalathar Zalathar Nov 8, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems worse than the status quo, as the call is now spread across several lines without an increase in clarity. I would at least retain msg as a local variable to make the call more compact.

View changes since the review

Comment on lines +150 to +152
// Set up the small-data optimization limit for architectures that use
// an LLVM argument to control this.
if let (Some(threshold), SmallDataThresholdSupport::LlvmArg(arg)) = (

@Zalathar Zalathar Nov 8, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're bothering to clean up this match, then IMO it should become an if-let chain rather than an odd if-let on a tuple.

View changes since the review

Comment on lines +52 to +59
pub(crate) fn set_struct_body(&self, ty: &'ll Type, els: &[&'ll Type]) {
unsafe { llvm::LLVMStructSetBody(ty, els.as_ptr(), els.len() as c_uint, FALSE) }
}

pub(crate) fn set_packed_struct_body(&self, ty: &'ll Type, els: &[&'ll Type]) {
unsafe { llvm::LLVMStructSetBody(ty, els.as_ptr(), els.len() as c_uint, TRUE) }
}

@Zalathar Zalathar Nov 8, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the sort of change that should be presented in its own commit at least, not bundled in with dozens of trivial changes.

View changes since the review

@malezjaa
malezjaa force-pushed the cleanup-llvm-codegen branch from 23fa2fa to c4fab04 Compare November 8, 2026 12:21
@rustbot

rustbot commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

These commits modify compiler targets.
(See the Target Tier Policy.)

Some changes occurred in GUI tests.

cc @GuillaumeGomez

This PR changes how LLVM is built. Consider updating src/bootstrap/download-ci-llvm-stamp.

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez, @lolbinarycat

Some changes occurred in src/tools/compiletest

cc @jieyouxu

Some changes occurred in src/tools/cargo

cc @weihanglo

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-rustdoc-js Area: Rustdoc's JS front-end A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Nov 8, 2026
@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@malezjaa

malezjaa commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

oh no, i messed up a rebase. let me fix it

@malezjaa
malezjaa force-pushed the cleanup-llvm-codegen branch from c4fab04 to 04cc725 Compare November 8, 2026 12:37
@rustbot

This comment has been minimized.

@malezjaa

malezjaa commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Sorry to everyone who got pinged 😅

I should've split these up into commit from the start.
Also I cleaned up remaining needless borrows. (all of them are in one commit)

@rust-bors

This comment has been minimized.

@malezjaa
malezjaa force-pushed the cleanup-llvm-codegen branch from 04cc725 to 6fa07e2 Compare November 8, 2026 14:24
@rustbot

rustbot commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@malezjaa
malezjaa force-pushed the cleanup-llvm-codegen branch from 6fa07e2 to 3ba6ed9 Compare November 11, 2026 15:32
@rust-bors

rust-bors Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #165844) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-compiletest Area: The compiletest test runner A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-rustdoc-js Area: Rustdoc's JS front-end A-testsuite Area: The testsuite used to check the correctness of rustc F-autodiff `#![feature(autodiff)]` S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants